package com.hrt.datasender.mq.model;

import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

/**
 * Opc数据消息体
 * 
 * @author wencheng
 *
 */
public class OpcModel extends MqModel {
    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    private Date dataTime;

    private HashMap<String, String> data;

    private String deviceName;

    public OpcModel(HashMap<String, String> data, String deviceName) {
        dataTime = new Date();
        this.data = data;
        this.deviceName = deviceName;
    }

    @Override
    public int getMqModelType() {
        return MqModel.MODEL_TYPE_DRIVE;
    }

    @Override
    public String toString() {
        String msg = "";
        Set<String> keys = data.keySet();
        Iterator<String> iterator = keys.iterator();
        while (iterator.hasNext()) {
            String key = iterator.next();
            String value = data.get(key);
            msg += key + ":" + value + ";";
        }

        return "SerialModel [msg=" + msg + "]";
    }

    public Date getDataTime() {
        return dataTime;
    }

    public void setDataTime(Date dataTime) {
        this.dataTime = dataTime;
    }

    public HashMap<String, String> getData() {
        return data;
    }

    public void setData(HashMap<String, String> data) {
        this.data = data;
    }

    public String getDeviceName() {
        return deviceName;
    }

    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }

}
